<tagLib name="html" />

<include file="Public:header" />

<div class="container" id="cpcontainer">
   <div class="itemtitle">
        <h3>{$Think.lang.ad.manage_adv}</h3>
        <ul class="tab1">
            <li><a href="__URL__/adList"><span>{$Think.lang.ad.all_ad}</span></a></li>
            <li class="current"><notempty name="rs.ad_id"><a href="__URL__/editAD/ad_id/{$rs.ad_id}"><span>{$Think.lang.ad.edit_ad}</span></a><else/><a href="__URL__/addAD"><span>{$Think.lang.ad.add_ad}</span></a></notempty></li>
            <li><a href="__URL__/locationList"><span>{$Think.lang.ad.all_location}</span></a></li>
            <li><a href="__URL__/addLocation"><span>{$Think.lang.ad.add_location}</span></a></li>
        </ul>
    </div>
    <p class="tips"></p>

    <form name="cpform" method="post" action="__ACTION__">
    <input type="hidden" name="op" value="save" />
    <input type="hidden" name="ad_id" value="{$rs.ad_id}" />
    <table class="tb tb2">
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.title}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="title" value="{$rs.title}" type="text" class="txt" /></td>
            <td class="vtop tips2">{$Think.lang.ad.ad_title_explain}</td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.ad_location}:</td></tr>
        <tr>
            <td class="vtop rowform">
                <select id="location" name="location_id" onchange="showLocationTips(this);">
                <volist name="locations" id="vo">
                    <option value="{$vo.location_id}" title="{$vo.description}" <eq name="vo.location_id" value="rs.location_id">selected</eq>>{$vo.identifier}</option>
                </volist>
                </select>
            </td>
            <td class="vtop tips2"><span id="location_tips"></span></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.start_time}:</td></tr>
        <tr>
            <td class="vtop rowform"><input id="date-pick1" name="start_time" value="<notempty name="rs.start_time">{$rs.start_time|format_date='Y-m-d'}</notempty>" type="text" class="txt" /></td>
            <td class="vtop tips2">{$Think.lang.ad.ad_time_explain}</td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.expire_time}:</td></tr>
        <tr>
            <td class="vtop rowform"><input id="date-pick2" name="expire_time" value="<notempty name="rs.expire_time">{$rs.expire_time|format_date='Y-m-d'}</notempty>" type="text" class="txt" /></td>
            <td class="vtop tips2">{$Think.lang.ad.ad_time_explain}</td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.ad_format}:</td></tr>
        <tr>
            <td class="vtop rowform">
                <html:select name="format" options="formatOptions" selected="formatSelected" onchange="switchFormat(this)" />
            </td>
            <td class="vtop tips2">{$Think.lang.ad.ad_format_explain}</td>
        </tr>

        <tbody id="format_html" style="display:none">
        <tr><th colspan="15" class="partition">{$Think.lang.ad.format_html}</th></tr>
        <tr class="nobg"><td colspan="2" class="td27"> {$Think.lang.ad.html_code}:</td></tr>
        <tr>
            <td class="vtop rowform"><textarea rows="6" onkeyup="textareasize(this)" name="ad[html][code]" id="ad[html][code]" cols="50" class="tarea">{$rs.parameter.code}</textarea></td>
            <td class="vtop tips2"></td>
        </tr>
        </tbody>

        <tbody id="format_text" style="display:none">
        <tr><th colspan="15" class="partition">{$Think.lang.ad.format_text}</th></tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.text_ad_content}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[text][title]" value="{$rs.parameter.title}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.text_ad_link}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[text][link]" value="{$rs.parameter.link}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.text_ad_fontsize}</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[text][size]" value="{$rs.parameter.size}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        </tbody>

        <tbody id="format_image" style="display:none">
        <tr><th colspan="15" class="partition">{$Think.lang.ad.format_image}</th></tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.image_file_url}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[image][file]" value="{$rs.parameter.file}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.image_link}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[image][link]" value="{$rs.parameter.link}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.image_width}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[image][width]" value="{$rs.parameter.width}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.image_height}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[image][height]" value="{$rs.parameter.height}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.image_alt}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[image][alt]" value="{$rs.parameter.alt}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        </tbody>

        <tbody id="format_flash" style="display:none">
        <tr><th colspan="15" class="partition">{$Think.lang.ad.format_flash}</th></tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.flash_file_url}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[flash][file]" value="{$rs.parameter.file}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.flash_width}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[flash][width]" value="{$rs.parameter.width}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        <tr class="nobg"><td colspan="2" class="td27">{$Think.lang.ad.flash_height}:</td></tr>
        <tr>
            <td class="vtop rowform"><input name="ad[flash][height]" value="{$rs.parameter.height}" type="text" class="txt" /></td>
            <td class="vtop tips2"></td>
        </tr>
        </tbody>
        <tr class="nobg"><td colspan="15"><div class="fixsel"><input class="btn" type="submit" value="{$Think.lang.submit}" /></div></td></tr>
    </table>
    </form>
</div>

<load href="__PUBLIC__/Js/datePicker/jquery.datePicker.css" />
<load href="__PUBLIC__/Js/datePicker/date.js" />
<load href="__PUBLIC__/Js/datePicker/jquery.datePicker.js" />

<script type="text/javascript">
$(function(){
    $('#location_tips').html($('#location').find("option:selected").attr('title'));
    var selectFormat = '{$rs.format}';
    if(selectFormat == ''){
        $('#format_html').show();
    }else{
        $('#format_'+selectFormat).show();
    }
    Date.format = 'yyyy-mm-dd';
    var params = {
        clickInput:true,
        startDate:'1996-01-01'
    };
	$('#date-pick1,#date-pick2').datePicker(params);
});

function showLocationTips(obj){
    $('#location_tips').html($(obj).find("option:selected").attr('title'));
}

function switchFormat(obj){
    var styles = new Array('html','text','image','flash');
    for(var i in styles){
        if($(obj).val() == styles[i]){
            $('#format_'+styles[i]).show();
        }else{
            $('#format_'+styles[i]).hide();
        }
    }
}
</script>

<include file="Public:footer" />